<?php

use App\Http\Controllers\JstController;
use Illuminate\Support\Facades\Route;

# 聚水潭代发
Route::prefix('jst')->middleware('api')->group(function ($route) {
    $route->any('token', JstController::class.'@getToken');
    $route->any('image/upload', JstController::class.'@uploadImage');
    $route->any('goods/upload', JstController::class.'@addSaleGoods');
});



# 退单
Route::namespace('Api')->prefix('refund')->middleware('api')->group(function ($route) {
    $route->any('save', RefundController::class.'@doSave');
    $route->any('cancel', RefundController::class.'@cancelRefund');
    $route->any('goods', RefundController::class.'@doRefundGoods');
    $route->any('agree', RefundController::class.'@doRefund');
    $route->any('update', RefundController::class.'@doUpdate');
    $route->any('express', RefundController::class.'@saveExpress');
});

# 免授权
Route::namespace('Api')->prefix('v1')->middleware('api')->group(function () {
    # APP授权和更新
    Route::prefix('auth')->group(function ($route) {
        $route->any('token', AuthController::class.'@getToken');
        $route->any('app/version', AuthController::class.'@getAppVersion');
        $route->any('app/save', AuthController::class.'@saveAppVersion');
        # 授权过期
        $route->any('login', AuthController::class.'@login')->name('login');
    });
    # 自动执行
    Route::prefix('auto')->group(function ($route) {
        $route->any('image_size', AutoController::class.'@getImageSize');
        $route->any('goods_images_size', AutoController::class.'@getGoodsImagesSize');
    });
    # 上传和产品详情
    Route::any('upload', UploadController::class.'@upload');
    Route::any('push', OrderController::class.'@test');
});


# 校验授权
Route::namespace('Api')->prefix('v1')->middleware('api')->group(function () {
    Route::prefix('asset')->group(function ($route) {
        $route->any('list', UploadController::class.'@getAssetList');
        $route->any('asset_info', UploadController::class.'@getGoodsAsset');
    });

    # 短信验证
    Route::prefix('verify')->group(function ($route) {
        $route->any('get', VerifyController::class.'@getVerify');
    });

    # 首页/推荐
    Route::prefix('home')->group(function ($route) {
        $route->any('index', HomeController::class.'@index');
        $route->any('video', HomeController::class.'@getBootVideo');
        $route->any('ad', HomeController::class.'@getImageSearchAd');
        $route->any('list', HomeController::class.'@getList');
        $route->any('save', HomeController::class.'@doSave');
        $route->any('delete', HomeController::class.'@doDelete');
    });
    # 配置
    Route::prefix('config')->group(function ($route) {
        $route->any('get', ConfigController::class.'@getConfig');
    });
    # 商家
    Route::prefix('supply')->group(function ($route) {
        $route->any('list', SupplyController::class.'@getList');
        $route->any('goods_list', SupplyController::class.'@getGoodsList');
        $route->any('info', SupplyController::class.'@getInfo');
        $route->any('save', SupplyController::class.'@doSave');
        $route->any('set_status', SupplyController::class.'@setStatus');
        $route->any('all', SupplyController::class.'@getAllSupply');
    });
    # 商品
    Route::prefix('goods')->group(function ($route) {
        $route->any('list', GoodsController::class.'@getList');
        $route->any('video_list', GoodsController::class.'@videoList');
        $route->any('keyword_search', GoodsController::class.'@keywordSearch');
        $route->any('image_search', GoodsController::class.'@imageSearch');
        $route->any('view', GoodsController::class.'@viewGoods');
        $route->any('download', GoodsController::class.'@getDownloadList');
        $route->any('goods_list', SpecController::class.'@getList');
        $route->any('goods_specs', SpecController::class.'@getGoodsSpec');
        $route->any('save_spec', SpecController::class.'@saveSpecs');
        $route->any('save_changes', SpecController::class.'@saveChangeSpec');
        $route->any('delete_spec', SpecController::class.'@deleteSpec');
        $route->any('set_stock', SpecController::class.'@setStock');
        $route->any('square_images', SpecController::class.'@getSquareImages');
        $route->any('info', GoodsController::class.'@goodsInfo');
    });
    # 收藏
    Route::prefix('fav')->group(function ($route) {
        $route->any('list', FavController::class.'@getList');
        $route->any('save', FavController::class.'@doSave');
        $route->any('delete', FavController::class.'@doDelete');
        $route->any('notice', FavController::class.'@noticeList');
    });
    # 发布
    Route::prefix('document')->group(function ($route) {
        $route->any('list', DocumentController::class.'@getList');
        $route->any('save', DocumentController::class.'@doSave');
        $route->any('delete', DocumentController::class.'@doDelete');
        $route->any('userList', DocumentController::class.'@getUserList');
        $route->any('praise', DocumentController::class.'@praise');
    });
    # 购物车
    Route::prefix('cart')->group(function ($route) {
        $route->any('list', CartController::class.'@getList');
        $route->any('web_list', CartController::class.'@getWebList');
        $route->any('save', CartController::class.'@doSave');
        $route->any('delete', CartController::class.'@doDelete');
    });
    # 地址
    Route::prefix('address')->group(function ($route) {
        $route->any('list', AddressController::class.'@getList');
        $route->any('save', AddressController::class.'@doSave');
        $route->any('delete', AddressController::class.'@doDelete');
        $route->any('ai', AddressController::class.'@aiAddress');
    });
    # 快递
    Route::prefix('express')->group(function ($route) {
        $route->any('list', ExpressController::class.'@getList');
        $route->any('save', ExpressController::class.'@doSave');
        $route->any('delete', ExpressController::class.'@doDelete');
        $route->any('fee', ExpressController::class.'@getExpressFee');
        $route->any('query', ExpressController::class.'@doQuery');
    });
    # 订单
    Route::prefix('order')->group(function ($route) {
        $route->any('list', OrderController::class.'@getList');
        $route->any('save', OrderController::class.'@doSave');
        $route->any('update', OrderController::class.'@doUpdate');
        $route->any('cancel', OrderController::class.'@cancelOrder');
        $route->any('finish', OrderController::class.'@finishOrder');
        $route->any('info', OrderController::class.'@getOrderInfo');
    });

    # 支付
    Route::prefix('pay')->group(function ($route) {
        $route->any('web', PayController::class.'@web');
        $route->any('app', PayController::class.'@app');
        $route->any('wap', PayController::class.'@wap');
        $route->any('query', PayController::class.'@query');
    });
    # 金币
    Route::prefix('gold')->group(function ($route) {
        $route->any('list', GoldController::class.'@getList');
        $route->any('add', GoldController::class.'@doSave');
        $route->any('query', GoldController::class.'@query');
        $route->any('pay_back', GoldController::class.'@payBack');
        $route->any('charge', GoldController::class.'@payBack');
        $route->any('pay', GoldController::class.'@payBack');
    });
    Route::prefix('vip')->group(function ($route) {
        $route->any('list', VipController::class.'@getList');
        $route->any('save', VipController::class.'@doSave');
    });
});
